# encoding: utf-8
class ApplicationController < ActionController::Base

  protect_from_forgery

  before_filter :process_subdomain
  helper_method :date_parts,:app_names,:app_display_name,:sort_column,:sort_direction

  def process_subdomain
    pp controller_name
    if request.subdomains.first == 'admin' and controller_name != 'sessions'
      if !current_admin
        redirect_to new_admin_session_path
      elsif controller_name == 'home'
        redirect_to admin_path
      end
    end
  end
  
  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_path, :alert => exception.message
  end
end
